<template>
  <div>
    昵称<input type="text" v-model="user.nickname" /><br />
    手机号码<input type="text" v-model="user.phone" /><br />
    密码<input type="text" v-model="user.password" /><br />

    验证码<input type="text" v-model="user.captcha" /><br />
    <button @click="captchaBtn">验证码</button>
    <br />
    <button @click="registerBtn">注册</button>
    <button @click="loginBtn">登录</button>
  </div>
</template>

<script>
import { register, captchaApi, loginApi } from "@/api/user";
export default {
  data() {
    return {
      user: {
        nickname: "binary1345",
        phone: "",
        password: "",
        captcha: "",
      },
    };
  },
  methods: {
    registerBtn() {
      register(this.user).then((res) => {
        console.log(res);
      });
    },
    async captchaBtn() {
      const res = await captchaApi({
        phone: this.user.phone,
      });
      console.log(res);
    },

    async loginBtn() {
      const res = await loginApi({
        phone: this.user.phone,
        password: this.user.password,
      });
      console.log(res);
    },
  },
};
</script>

<style>
</style>